<nav class="ease2">
    <ul>
        <li class="blank-head"><a href="javascript:;"></a></li>
        <li class="area">
            <div>
                <i class="nav-icons"><img src="[{$Think.const.IMG_URL}]zb.png"</img></i>
                [{foreach userlist as $k=>$v }]
                <div id="college">[{$v.school_name}]</div>
                [{/foreach}]
            </div>
        </li>
        <div id="xgpersonal" class="button" data-type="l" style="width:110px;">完善信息</div>
        <div id="goodsfb" class="button" data-type="l" style="width:110px;">发布的商品</div>
        <div id="xggoods" class="button" data-type="l" style="width:110px;">商品信息修改</div>
        <div id="goodsdel" class="button" data-type="l" style="width:110px;">商品删除</div>
        <div id="post" class="button" data-type="l" style="width:110px;">帖子管理</div>
        <div id="msgtongzhi" class="button" data-type="l" style="width:110px;">消息通知<span style="color:red;">([{$tz}])</span></div>
        <div id="modifypw" class="button" data-type="l" style="width:110px;">修改密码</div>
        <div id="renzheng" class="button" data-type="l" style="width:110px;">认证</div>
    </ul>
</nav>
<script type="text/javascript">
    $(document).ready(function(){
        $("#xgpersonal").click(function () {
            window.location.href = "[{$Think.const.APP_HOME_URL}]Personal/xgpersonal";
        });
        $("#modifypw").click(function () {
            window.location.href = "[{$Think.const.APP_HOME_URL}]Personal/modifypw";
        });
        $("#goodsfb").click(function () {
            window.location.href = "[{$Think.const.APP_HOME_URL}]Personal/goodsfb";
        });
        $("#xggoods").click(function () {
            window.location.href = "[{$Think.const.APP_HOME_URL}]Personal/xggoods";
        });
        $("#post").click(function () {
            window.location.href = "[{$Think.const.APP_HOME_URL}]Personal/post";
        });
        $("#goodsdel").click(function () {
            window.location.href = "[{$Think.const.APP_HOME_URL}]Personal/goodsdel";
        });
        $("#msgtongzhi").click(function () {
            window.location.href = "[{$Think.const.APP_HOME_URL}]Personal/msgtongzhi";
        });
        $("#renzheng").click(function () {
            window.location.href = "[{$Think.const.APP_HOME_URL}]Personal/renzheng";
        });
    });
</script>
<!--一个jq，用来选择商品后，就显示要修改的信息-->
<script type="text/javascript">
    $(document).ready(function () {
        $("#select_goods").change(function () {
            var goods_id = $("#select_goods option:selected").attr("value");
            $.ajax({
                type: "POST",
                url: "[{$Think.const.APP_HOME_URL}]Personal/xggoods_msg",
                data: "goods_id=" + goods_id,
                dataType:'json',
                async: true, //默认为true 异步
                error: function () {
                    alert('出错');
                },
                success: function (msg) {
                    if(goods_id == 0){
                        $('#goods_name').attr('value','');
                        $('#cost_price').attr('value','');
                        $('#ershou_price').attr('value','');
                        $('#goods_place').attr('value','');
                        $('#goods_new').attr('value','');
                        $('#goods_jiangjia').attr('value','');
                        $('#goods_number').attr('value','');
                        $('#user_qq').attr('value','');
                        $('#user_tel').attr('value','');
                        $('#keywords').attr('value','');
                    }
                    $('#goods_name').attr('value',msg.goods_name);
                    $('#cost_price').attr('value',msg.cost_price);
                    $('#ershou_price').attr('value',msg.ershou_price);
                    $('#goods_place').attr('value',msg.goods_place);
                    $('#goods_new').attr('value',msg.goods_new);
                    $('#goods_jiangjia').attr('value',msg.goods_jiangjia);
                    $('#goods_number').attr('value',msg.goods_number);
                    $('#user_qq').attr('value',msg.user_qq);
                    $('#user_tel').attr('value',msg.user_tel);
                    $('#keywords').attr('value',msg.keywords);
                }
            });
        });
    });
</script>
<style>
    #xggoodsform input{
        font-size:15px;
        border:1px solid #646464;
    }
</style>
<form id="xggoodsform" action="[{$Think.const.APP_HOME_URL}]Personal/xggoods" method="post">
    <table style="margin:100px 0 0 500px;font-size:18px;">
        <tr>
            <td width="20%">选择商品</td>
            <td>
                <select name="goods_id" id="select_goods" style="font-size:15px;width:167px;">
                    <option value="0">默认</option>
                    <!--循环出栏目名-->
                    [{foreach goods as $k=>$v }]
                    <option value="[{$v.goods_id}]">[{$v.goods_name}]</option>
                    [{/foreach}]
                </select>
            </td>
        </tr>
        <tr>
            <td width="20%">新的商品名</td>
            <td><input type="text" id="goods_name" name="goods_name" value=""/></td>
        </tr>
        <tr>
            <td width="20%">交易地点</td>
            <td><input type="text" id="goods_place" name="goods_place" value=""/></td>
        </tr>
        <tr>
            <td width="20%">原价</td>
            <td><input type="text" id="cost_price" name="cost_price" value=""/></td>
        </tr>
        <tr>
            <td width="20%">二手价</td>
            <td><input type="text" id="ershou_price" name="ershou_price" value=""/></td>
        </tr>
        <tr>
            <td width="20%">商品数目</td>
            <td><input type="text" id="goods_number" name="goods_number" value=""/></td>
        </tr>
        <tr>
            <td width="20%">QQ</td>
            <td><input type="text" id="user_qq" name="user_qq" value=""/></td>
        </tr>
        <tr>
            <td width="20%">手机</td>
            <td><input type="text" id="user_tel" name="user_tel" value=""/></td>
        </tr>
        <tr>
            <td width="20%">是否卖出</td>
            <td>
                <select name="is_delete" id="is_delete" style="font-size:15px;width:167px;">
                    <option value="0">未卖出</option>
                    <option value="1">已卖出</option>
                </select>
            </td>
        </tr>
        <tr>
            <td ></td>
            <td>
                <input style="margin-left:25%;height:30px;width:50px;cursor:pointer;" class="xiugai" type="submit">
            </td>
        </tr>
    </table>
    <!--一个简单的jq，验证修改的数据-->
    <script type="text/javascript">
        $(document).ready(function () {
            var a = /^(0|([1-9]\d*))(\.\d+)?$/;     //正数字正则
            var b = /^[1-9]\d{4,12}$/;   //qq正则5到13位，首位不能为0
            var c = /^1[34578]\d{9}$/; //电话号码正则
            $(".xiugai").click(function () {
                if($('#select_goods').val() == 0){
                    alert('请选择商品');
                    return false;
                }
                var cost_price = $("#cost_price").val();     //原价格
                var ershou_price = $("#ershou_price").val();     //二手价格
                var goods_number = $("#goods_number").val();     //数量
                var qq = $("#user_qq").val();     //qq
                var tel = $("#user_tel").val();     //电话
                var name = $("#goods_name").val();     //商品名
                var place = $("#goods_place").val();     //交易地方

                if(tel == '' && qq == ''){
                    alert('手机或者QQ必填一个');
                    return false;
                }
                if(ershou_price == ''){
                    alert('价格不能为空');
                    return false;
                }
                if(!a.test(ershou_price)){
                    alert('价格只能为正数');
                    return false;
                }
                if(cost_price == ''){
                    alert('原价格不能为空');
                    return false;
                }
                if(!a.test(cost_price)){
                    alert('价格只能为正数');
                    return false;
                }
                if(goods_number == ''){
                    alert('数量不能为空');
                    return false;
                }
                if(!a.test(goods_number)){
                    alert('数量只能为1-1000000的整数');
                    return false;
                }
                if(qq != ''){
                    if(!b.test(qq)){
                        alert('QQ格式错误');
                        return false;
                    }
                }
                if(tel != ''){
                    if(!c.test(tel)){
                        alert('手机格式错误');
                        return false;
                    }
                }
                if(name.length > '20' || name == ''){
                    alert('商品名不能超过20个字符');
                    return false;
                }
                if(place.length > '20' || place == ''){
                    alert('交易地点字数有问题');
                    return false;
                }
                $("#addgoodsform").submit();
            });
        });
    </script>
</form>